(in-package :TRAPS)
; Generated from #P"macintosh-hd:hd3:CInterface Translator:Source Interfaces:frame.h"
; at Sunday July 2,2006 7:24:05 pm.
; 
;  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
;  *
;  * @APPLE_LICENSE_HEADER_START@
;  * 
;  * The contents of this file constitute Original Code as defined in and
;  * are subject to the Apple Public Source License Version 1.1 (the
;  * "License").  You may not use this file except in compliance with the
;  * License.  Please obtain a copy of the License at
;  * http://www.apple.com/publicsource and read it before using this file.
;  * 
;  * This Original Code and all software distributed under the License are
;  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
;  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
;  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
;  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
;  * License for the specific language governing rights and limitations
;  * under the License.
;  * 
;  * @APPLE_LICENSE_HEADER_END@
;  
; 
;  * Copyright (c) 1992 NeXT Computer, Inc.
;  *
;  * Intel386 Family:	Processor exception frame.
;  *
;  * HISTORY
;  *
;  * 31 August 1992 ? at NeXT
;  *	Added v86 mode stuff.
;  *
;  * 8 June 1992 ? at NeXT
;  *	Changed name of write field in err_code_t
;  *	which collided with write() in shlib.
;  *
;  * 30 March 1992 ? at NeXT
;  *	Created.
;  
; 
;  * Format of the error code
;  * generated by the hardware
;  * for certain exceptions.
;  
(defrecord err_code
   (:variant
   (
   (ext :UInt32)                                ;(: 1)
                                                ;(tbl : 2)
(defconstant $ERR_GDT 0)
; #define ERR_GDT		0
(defconstant $ERR_IDT 1)
; #define ERR_IDT		1
(defconstant $ERR_LDT 2)
; #define ERR_LDT		2
                                                ;(index : 13)
                                                ;(: 16)
   )
   (
   (prot :UInt32)                               ;(: 1)
                                                ;(wrtflt : 1)
                                                ;(user : 1)
                                                ;(: 29)
   )
   )
)

(require-interface "architecture/i386/sel")
; 
;  * The actual hardware exception frame
;  * is variable in size.  An error code is
;  * only pushed for certain exceptions.
;  * Previous stack information is only
;  * pushed for exceptions that cause a
;  * change in privilege level.  The dpl
;  * field of the saved CS selector can be
;  * used to determine whether this is the
;  * case.  If the interrupted task was
;  * executing in v86 mode, then the data
;  * segment registers are also present in
;  * the exception frame (in addition to
;  * previous stack information).  This
;  * case can be determined by examining
;  * eflags.
;  
(defrecord except_frame
   (err :err_code_t)
#|
; Warning: type-size: unknown type ERR_CODE_T
|#
   (eip :UInt32)
   (cs :SEL)
   (colon12 :UInt32)
   (eflags :UInt32)
   (esp :UInt32)
   (ss :SEL)
   (colon1 :UInt32)
   (v_es :UInt16)
   (colon14 :UInt32)
   (v_ds :UInt16)
   (colon4 :UInt32)
   (v_fs :UInt16)
   (colon12 :UInt32)
   (v_gs :UInt16)
   (colon12 :UInt32)
)
(%define-record :except_frame_t (find-record-descriptor :EXCEPT_FRAME))
; 
;  * Values in eflags.
;  
; #ifndef	EFL_CF	/* FIXME */
(defconstant $EFL_CF 1)
; #define EFL_CF		0x00001
(defconstant $EFL_PF 4)
; #define EFL_PF		0x00004
(defconstant $EFL_AF 16)
; #define EFL_AF		0x00010
(defconstant $EFL_ZF 64)
; #define EFL_ZF		0x00040
(defconstant $EFL_SF 128)
; #define EFL_SF		0x00080
(defconstant $EFL_TF 256)
; #define EFL_TF		0x00100
(defconstant $EFL_IF 512)
; #define EFL_IF		0x00200
(defconstant $EFL_DF 1024)
; #define EFL_DF		0x00400
(defconstant $EFL_OF 2048)
; #define EFL_OF		0x00800
(defconstant $EFL_IOPL 12288)
; #define EFL_IOPL	0x03000
(defconstant $EFL_NT 16384)
; #define EFL_NT		0x04000
(defconstant $EFL_RF 65536)
; #define EFL_RF		0x10000
(defconstant $EFL_VM 131072)
; #define EFL_VM		0x20000
(defconstant $EFL_AC 262144)
; #define EFL_AC		0x40000

; #endif

(defconstant $EFL_CLR 4294475816)
; #define EFL_CLR		0xfff88028
(defconstant $EFL_SET 2)
; #define EFL_SET		0x00000002

(provide-interface "frame")